package jettyutils;

import java.io.IOException;
import java.util.Properties;

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;

public class JettyUtils {
	private static String PATH=null;
	private static String PORT="80";
	private static String VISITPATH=null;
	
	static{
		Properties pro = new Properties();
		try {
			pro.load(JettyUtils.class.getResourceAsStream("jetty.properties"));
			PATH = pro.getProperty("path");
		    PORT = pro.getProperty("port");
		    VISITPATH=pro.getProperty("viewpath");
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
	private JettyUtils() {
	}
	public static void main(String[] args) throws Exception {
		Server server=new Server(Integer.parseInt(PORT));
		WebAppContext app=new WebAppContext();
		app.setDescriptor(PATH + "/WEB-INF/web.xml");
		app.setResourceBase(PATH);
		app.setContextPath(VISITPATH);
		server.setHandler(app);
		server.start();
		server.join();
	}

}
